package com.oocl.main;

import java.io.File;
import java.io.FileNotFoundException;
import java.text.SimpleDateFormat;
import java.util.Scanner;

import com.oocl.service.SetServices;
import com.oocl.struct.Customer;
import com.oocl.util.FormatInput;

public class Main {
	public static void main(String[] args) throws Exception {
		SetServices setServices = new SetServices();
		Scanner scanner = new Scanner(new File("date.txt"));
		SimpleDateFormat db = new SimpleDateFormat("YYYY-MM-dd");
		while(scanner.hasNext()){
			String string = scanner.nextLine();
			if(FormatInput.isValid(string)){
				String[] strings = string.split("\\s+");
				Customer customer = new Customer(Integer.parseInt(strings[0]), 
						strings[1], strings[2], Boolean.parseBoolean(strings[3]), db.parse(strings[4]));
				setServices.addCustomer(customer);
			}
		}
		
		setServices.printById();
		
		setServices.printByBirth();
		
		setServices.printXML();
	}

}
